﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter10
{
    public class MainWindowViewModel
    {
        private List<Unit> unit;

        public MainWindowViewModel()
        {
            unit = new List<Unit>();
            unit.Add(new Unit { Num = 1, Title = "概述" });
            unit.Add(new Unit { Num = 2, Title = "集合接口和类型" });
            unit.Add(new Unit
            {
                Num = 3,
                Title = "列表",
                Sample = "ListSamples",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 3.1, Title = "创建列表" }, 
                    new Unit { Num = 3.2, Title = "只读集合" } 
                }
            });
            unit.Add(new Unit { Num = 4, Title = "队列", Sample = "QueueSample" });
            unit.Add(new Unit { Num = 5, Title = "栈", Sample = "StackSample" });
            unit.Add(new Unit { Num = 6, Title = "链表", Sample = "LinkedListSample" });
            unit.Add(new Unit { Num = 7, Title = "有序列表", Sample = "SortedListSample" });
            unit.Add(new Unit
            {
                Num = 8,
                Title = "字典",

                ChildCatalogues = new List<Unit>
                { 
                    new Unit { Num = 8.1, Title = "键的类型" }, 
                    new Unit { Num = 8.2, Title = "字典示例", Sample = "DictionarySample" }, 
                    new Unit { Num = 8.3, Title = "Lookup 类", Sample = "LookupSample" },
                    new Unit { Num = 8.4, Title = "有序字典" }
                }
            });
            unit.Add(new Unit { Num = 9, Title = "集", Sample = "SetSample" });
            unit.Add(new Unit { Num = 10, Title = "可观察集合", Sample = "ObservableCollectionSample" });
            unit.Add(new Unit
            {
                Num = 11,
                Title = "位数组",
                Sample = "BitArrarySample",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 11.1, Title = "BitArray 类" }, 
                    new Unit { Num = 11.2, Title = "BitVector32 结构" } 
                }
            });
            unit.Add(new Unit
            {
                Num = 12,
                Title = "并发集合",
                Sample = "PipelineSample",
                ChildCatalogues = new List<Unit>
                { 
                    new Unit { Num = 12.1, Title = "创建管道" },
                    new Unit { Num = 12.2, Title = "使用 BlockingCollcetion" }, 
                    new Unit { Num = 12.3, Title = "使用 ConcurrentDictionary" }, 
                    new Unit { Num = 12.4, Title = "完成管道" } 
                }
            });
            unit.Add(new Unit { Num = 13, Title = "性能" });
            unit.Add(new Unit { Num = 14, Title = "小结" });
        }

        public List<Unit> Catalogues
        {
            get { return unit; }
        }

        public class Unit
        {
            public double Num { get; set; }
            public string Title { get; set; }
            public string Sample { get; set; }
            public List<Unit> ChildCatalogues { get; set; }
        }

        public override string ToString()
        {
            return "第10章 集合";
        }
    }
}
